package com.g2.admin.model.po;

import java.util.Date;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.g2.admin.common.constant.StatusTypeEnums;
import com.g2.admin.controller.LoginController;
import io.swagger.annotations.ApiModelProperty;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

/**
 * 账号信息表
 **/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "user_account")
public class UserAccountPo implements Serializable {
	private static final long serialVersionUID = -745187905974494800L;

	@ApiModelProperty(value = "头像")
	private String avatar;
	@ApiModelProperty(value = "创建时间")
	private Date createTime;
	@TableId(value = "id", type = IdType.AUTO)
    private Long id;
	@ApiModelProperty(value = "名称")
	private String name;
	@ApiModelProperty(value = "单位ID，所属单位，管理员则为空")
	private Long orgId;
	@ApiModelProperty(value = "单位名称")
	private String orgName;
	@ApiModelProperty(value = "密码")
	@NotNull(message = "密码不能为空")
	private String password;
	@ApiModelProperty(value = "关联ID（如果有其他扩展角色，可以利用此字段关联）")
	private Long relationId;
	@ApiModelProperty(value = "备注")
	private String remark;
	@ApiModelProperty(value = "盐值")
	private String slat;
	@ApiModelProperty(value = "用户状态：1、正常；2、禁用；3、删除。")
	private StatusTypeEnums.StatusEnums status;
	@ApiModelProperty(value = "用户类型：1、管理员；2、业务员。")
	private Integer type;
	@ApiModelProperty(value = "更新时间")
	private Date updateTime;
	@ApiModelProperty(value = "用户名")
	@NotNull(message = "用户名不能为空")
	private String username;
	@ApiModelProperty(value = "验证码")
	@TableField(exist = false)
	@NotNull(message = "验证码不能为空", groups = {LoginController.class})
	private String code;

	public static void cleanSensitiveInfo(UserAccountPo userAccount) {
		userAccount.setSlat("");
		userAccount.setPassword("");
	}
}